package com.gscitysfy.cus.drain.modules.command.dto;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author jiang_wen
 * @Date 2022/10/20 19:19
 * @Description 分页实体
 */
public class IPageDto {

    private static final int DEFAULT_PAGESIZE = 10;

    private static final int MAX_PAGESIZE = 10000;
    /**
     * 当前页
     */
    private long currentPage = 1;
    /**
     * 当前页
     */
    private long pageSize = 10;
    /**
     * 当前页
     */
    private long current = 1;

    /**
     * 每页显示条数
     */
    private long size = 10;

    /**
     * 查询条件
     */
    private Map<String, Object> cm = new HashMap<String, Object>();

    public long getCurrent() {
        return current;
    }

    public void setCurrent(long current) {
        this.current = current;
    }

    public long getSize() {
        if (size <= 0) {
            size = DEFAULT_PAGESIZE;
        }
        if (size > MAX_PAGESIZE) {
            size = MAX_PAGESIZE;
        }
        return size;
    }

    public long getCurrentPage() {
        return getCurrent();
    }

    public void setCurrentPage(long currentPage) {
        this.current = currentPage;
    }

    public long getPageSize() {
        return getSize();
    }

    public void setPageSize(long pageSize) {
        this.size = pageSize;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public Map<String, Object> getCm() {
        return cm;
    }

    public void setCm(Map<String, Object> cm) {
        this.cm = cm;
    }

    public Page getPage() {
        Page page = new Page();
        page.setCurrent(getCurrent());
        page.setSize(getSize());
        return page;
    }
}
